FROM node:18.19.1 as builder
WORKDIR /app

# 安装pnpm
RUN corepack enable pnpm
# 提前安装依赖， 避免每次安装依赖花很久时间
# 只要 package.json 不修改就会用 docker cache
COPY package.json /app
COPY package-lock.json /app

RUN pnpm install --registry=https://registry.npmmirror.com

ADD . /app

RUN pnpm build

FROM nginx
COPY --from=builder /app/dist/ /usr/share/nginx/html/admin/
COPY nginx/default.conf /etc/nginx/conf.d
